package cn.hesion.leetcode;
/**
 * ClassName: CountTriplets <br/>
 * Description: <br/>
 * date: 2022/5/24 21:58<br/>
 *
 * @author Hesion<br />
 * @version
 * @since JDK 1.8
 */

import java.util.ArrayList;
import java.util.Arrays;

/**
 * 1442. 形成两个异或相等数组的三元组数目
 * @author: hesion
 * @create: 2022-05-24 21:58
 **/
public class CountTriplets {
    public int countTriplets(int[] arr) {
        int n = arr.length;
        int[] prefix = new int[n+1];
        for (int i = 0; i < n; ++i) {
            prefix[i+1] = prefix[i]^arr[i];
        }
        int ans = 0;
        for (int i = 0; i < n; ++i) {
            for(int j=i+1;j<n;++j){
                for (int k = j; k < n; ++k) {
                    if(prefix[i]==prefix[k+1]){
                       ++ans;
                    }
                }
            }
        }

        return ans;
    }


    public static void main(String[] args) {
        System.out.println(new CountTriplets().countTriplets(new int[]{1,1,1,1,1}));
    }
}
